import ACCESS_EUNM from "./ACCESS_EUNM";

const verifyAccess = (
  loginUser: any,
  needAccess: string = ACCESS_EUNM.LOGIN_FAILURE
) => {
  const nowAccess = loginUser?.userRole ?? ACCESS_EUNM.LOGIN_FAILURE;
  if (needAccess === ACCESS_EUNM.LOGIN_FAILURE) {
    return true;
  }
  if (needAccess === ACCESS_EUNM.LOGIN_SUCCESS) {
    if (needAccess !== ACCESS_EUNM.LOGIN_FAILURE) {
      return true;
    }
    return false;
  }
  if (needAccess === ACCESS_EUNM.ADMIN) {
    if (nowAccess === ACCESS_EUNM.ADMIN) {
      console.log("2");

      return true;
    }
    return false;
  }
};
export default verifyAccess;
